<?php
declare(strict_types=1);
namespace App\Controller\Cash\v1;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Annotation\Middleware;
use Hyperf\Di\Annotation\Inject;
use Service\GoodsService\CashGoodsService;
use Service\ActivityService\ActivityService;
use App\Middleware\CashMiddleware;

/**
 * 商品中心控制器
 * @author chenshubo
 * @Controller(prefix="/cash/v1/goods")
 * @Middleware(CashMiddleware::class)
 */
class GoodsController extends AbstractController
{
    /**
     * @Inject
     * @var CashGoodsService
     */
    protected $cashGoodsService;
    
    /**
     * @Inject
     * @var ActivityService
     */
    protected $activityService;
    
    /**
     * 商品分类
     * @RequestMapping(path="getGlobalClass", methods="post")
     */
    public function getGlobalClass(RequestInterface $request)
    {
        return $this->cashGoodsService->getGlobalClass($request->getAttribute('cid'),$request->getAttribute('mn_sid'),$request->getParsedBody());
    }
    
    /**
     * 商品列表
     * @RequestMapping(path="getGoodsList", methods="post")
     */
    public function getGoodsList(RequestInterface $request)
    {
        return $this->cashGoodsService->getGoodslist($request->getAttribute('cid'),$request->getAttribute('mn_sid'),$request->getParsedBody());
    }
    
    /**
     * 活动列表
     * @RequestMapping(path="getActivity", methods="post")
     */
    public function getActivity(RequestInterface $request)
    {
        return $this->activityService->getActivity($request->getAttribute('cid'),$request->getAttribute('mn_sid'),$request->getParsedBody());
    }
    
    /**
     * 特价活动列表
     * @RequestMapping(path="getActivitySpecial", methods="post")
     */
    public function getActivitySpecial(RequestInterface $request)
    {
        return $this->activityService->getActivitySpecial($request->getAttribute('cid'),$request->getAttribute('mn_sid'),$request->getParsedBody());
    }
}